<template>
  <div>
  <div class="login">
    <el-form v-model="OrderList" label-width="120px" class="login-box">
      <h3 class="login-title">订单修改</h3>


    

    

      <el-form-item label="商品ID" prop="proId">
        <el-input type="text" placeholder="请输入ID" v-model="OrderList.proId" />
      </el-form-item>
      <el-form-item label="用户ID" prop="userId">
        <el-input type="text" placeholder="请输入ID" v-model="OrderList.userId" />
      </el-form-item>

     
       <el-form-item label="支付方式" prop="paymentType">
        <el-input type="text" placeholder="请输入支付方式" v-model="OrderList.paymentType" />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-input type="text" placeholder="请输入状态" v-model="OrderList.status" />
      </el-form-item>

      
      <el-form-item >
        <el-button type="primary" @click="updateOrder()">修改</el-button>
       
        <router-link to="/admin/manageOrders"> <el-button type="primary" >返回</el-button></router-link>
      </el-form-item>
    </el-form>
</div>

</div>
</template>

<script>
export default {
  name:'OrderUpdate',
  data(){
    return{
    OrderUpdateID:'',
    OrderList:{
         id:'',
      
         proId:'',
         userId:'',
         orderDate:'',
         paymentType:'',
         status:''
    }

  }
 },methods:{
   //用于获取订单的数据用于修改回显
   getOrderdata:function(){
     this.OrderUpdateID=this.$route.params.UpdateId
     this.$axios.get("/order/getOrderdata",{params:{id:this.OrderUpdateID}}).then(res=>{
       this.OrderList=res.data;
       console.log(this.OrderList)
     })
   },
   updateOrder:function(){
     var admin=localStorage.getItem("admin")
     this.$axios.get("/order/updateOrder",{params:{id:this.OrderList.id,proId:this.OrderList.proId,userId:this.OrderList.userId,paymentType:this.OrderList.paymentType,status:this.OrderList.status,admin:admin}}).then(res=>{
       this.$router.push({
         path:"/admin/manageOrders"
       })
     })
   }
 },
 mounted(){
   this.getOrderdata()
 }
}
</script>

<style>
.login-box {
  border: 1px solid #DCDFE6;
  width: 600px;
  margin: 180px auto;
  padding: 35px 35px 15px 35px;
  border-radius: 5px;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  box-shadow: 0 0 25px #909399;
  position: absolute;
  top:-175px;
  left: 3px;
 
 
}

.login {
  max-width:600px;
  margin: 60px auto;
  background: #fff;
  padding: 20px 40px;
  border-radius: 10px;
  position: relative;
  z-index: 9;
 
}
</style>